<?php
declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class RepairTaskWorkOrderRelationTable extends AbstractMigration
{
    public function up()
    {
        $table = $this->table('repair_task_work_order_relation', ['id' => false, 'primary_key' => ['id'], 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '返修工单关联表']);
        $table->addColumn('id', 'integer', ['identity' => true, 'signed' => false, 'limit' => 11, 'comment' => '主键ID'])
            ->addColumn('task_work_order_id', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '发起返修的工单id'])
            ->addColumn('task_repair_order_id', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '返修单id'])
            ->addIndex(['task_work_order_id', "task_repair_order_id"], ['unique' => true, 'name' => 'idx_task_work_order_repair_order'])
            ->save();
    }

    public function down()
    {
        $this->table('repair_task_work_order_relation')->drop()->save();
    }
}
